<div class="row">
    <div class="col-sm-6">
        <div class="panel panel-success">
            <div class="panel-heading">
                <h3 class="panel-title">A cobrar</h3>
            </div>
            <form name="frmDetalleCobrar" method="POST" role="form">
                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>Id</th>
                                    <th>Descripcion</th>
                                    <th>
                                        <abbr title="Precio Unitario">PU</abbr>
                                    </th>
                                    <th>Cantidad</th>
                                    <th>Importe</th>
                                    <th>Acciones</th>
                                </tr>
                            </thead>
                            <tbody>
                                {table_1_content}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="form-group">
                        <label class=" col-sm-offset-8 col-sm-1" for="txtTotal">Total:</label>
                        <div class="col-sm-3">
                            <input id="txtTotal" class="form-control" type="number" value="{Total}" readonly="readonly" />
                        </div>
                    </div>
                    <button id="btnCobrar" class="btn btn-default" type="submit" name="btnConfirmar" formaction="index.php?do=/caja/index_confirm">
                        <span class="glyphicon glyphicon-ok"></span> Confirmar
                    </button>
                </div>
            </form>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="panel panel-warning">
            <div class="panel-heading">
                <h3 class="panel-title">Pedidos</h3>
            </div>
            <div class="panel-body">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Busqueda</h3>
                    </div>
                    <div class="panel-body">
                        <form class="form-inline" name="frmCajaFiltros" method="POST" role="form">
                            <div class="form-group">
                                <label class="sr-only" for="txtLegajo">DNI o ID Pedido</label>
                                <input id="txtDNI_IDPedido" class="form-control" type="number" name="txtDNI_IDPedido" step="1" min="1" placeholder="DNI o ID Pedido">
                            </div>
                            <button class="btn btn-default" type="submit" name="btnFiltrar">
                                <span class="glyphicon glyphicon-filter"></span> Filtrar
                            </button>
                        </form>
                    </div>
                </div>
                <form name="frmPedidosTerminados" method="POST" role="form">
                    <div class="table-responsive">
                        <table class="table table-hover">    
                            <thead>
                                <tr>
                                    <th>Id</th>
                                    <th>DNI</th>
                                    <th>Nombre</th>
                                    <th>Apellido</th>
                                    <th>Fecha</th>
                                    <th>Franja</th>
                                    <!-- <th>Legajo/Usuario</th>
                                    <th>Comentario</th>
                                    <th>Anillado</th> -->
                                    <!-- <th>Retiro</th>
                                    <th>Horario</th>
                                    <th>Estado</th> -->
                                    <th>Acciones</th>
                                </tr>
                            </thead>
                            <tbody>
                                {table_2_content}
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
        </div>
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">Otros</h3>
            </div>
            <div class="panel-body">
                <form name="frmAgregarItem" method="POST" role="form">
                    <input type="hidden" name="hidAnillado" value="{Anillado}" />
                    <input type="hidden" name="hidSimpleFaz" value="{SimpleFaz}" />
                    <input type="hidden" name="hidDobleFaz" value="{PrecioCEIT}" />
                    <input type="hidden" name="hidIdUniqueItem" value="{IdUniqueItem}" />
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>Id Item</th>
                                    <!-- <th>Descripcion</th>
                                    <th>
                                        <abbr title="Precio Unitario">PU</abbr>
                                    </th> -->
                                    <th>Cantidad</th>
                                    <th>Importe</th>
                                    <th>Acciones</th>
                                </tr>    
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <select class="form-control" name="ddlItemTipo">
                                            <option disabled="disabled" selected="selected">Seleccione un item</option>
                                            <option value="ANI">Anillado</option>
                                            <option value="LIB">Art. de Libreria</option>
                                            <option value="FSF">Fot Sueltas - Simple Faz</option>
                                            <option value="FDF">Fot Sueltas - Doble Faz</option>
                                            <option value="PES">P. Especial - Simple Faz</option>
                                            <option value="PED">P. Especial - Doble Faz</option>
                                        </select>
                                        <!-- <input class="form-control" name="txtIdItem" type="text" required="required" /> -->
                                    </td>
                                    <!-- <td>
                                        <input class="form-control" name="txtDescripcion" type="text" required="required" />
                                    </td>
                                    <td>
                                        <input class="form-control" name="txtPrecioUnitario" type="number" min="0" step="0.05" required="required" />
                                    </td> -->
                                    <td>
                                        <input class="form-control" name="txtCantidad" type="number" min="1" step="1" value="1" required="required" readonly="readonly" />
                                    </td>
                                    <td>
                                        <input class="form-control" name="txtImporte" type="number" min="0" step="0.05" />
                                    </td>
                                    <td>
                                        <button class="btn btn-success btn-sm" name="btnAgregarItem" type="submit">
                                            <span class="glyphicon glyphicon-plus"></span>
                                        </button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-offset-9 col-sm-3">
                <button class="btn btn-info" type="button" name="btnCierreCaja">
                    <span class="glyphicon glyphicon-lock"></span> Cierre de Caja
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('select[name=ddlItemTipo]').change(function() {
        switch($('select[name=ddlItemTipo]').val()) {
            case "ANI":
                $("input[name=txtImporte]").val($("input[name=hidAnillado]").val());
                $("input[name=txtImporte]").attr("readonly", "readonly");
                $('input[name=txtCantidad]').val(1);
                //$('input[name=txtCantidad]').attr("readonly", "readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
            break;
           
            case "LIB":
                $("input[name=txtImporte]").val("");
                $('input[name=txtImporte]').removeAttr("readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
                break;
                
            case "FSF":
                $("input[name=txtImporte]").val($("input[name=hidSimpleFaz]").val());
                $("input[name=txtImporte]").attr("readonly", "readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
                break;
            
            case "FDF":
                $("input[name=txtImporte]").val($("input[name=hidDobleFaz]").val());
                $("input[name=txtImporte]").attr("readonly", "readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
                break;
                
            case "PES":
                $("input[name=txtImporte]").val($("input[name=hidSimpleFaz]").val());
                $("input[name=txtImporte]").attr("readonly", "readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
                break;
            
            case "PED":
                $("input[name=txtImporte]").val($("input[name=hidDobleFaz]").val());
                $("input[name=txtImporte]").attr("readonly", "readonly");
                $('input[name=txtCantidad]').removeAttr("readonly");
                break;
            
            default:
                $("input[name=txtImporte]").val("");
                break;
        }
    });

    $("button[name=btnCierreCaja]").click(function() {
        $.ajax({
            url: "index.php?do=/caja/ajax_get_cierre_caja",
            type: "GET",
            async: true,
            dataType: "json"
        })
        .done(function(msg) {
            alert("Total hasta el momento: $" + msg[0].Total + " " + msg[0].Tiempo);
        });
    });
    /*$('input[name=txtPrecioUnitario]').change(function() {
     var precio = $('input[name=txtPrecioUnitario]').val();
     var cant = $('input[name=txtCantidad]').val();
     var importe = precio * cant;
     
     $('input[name=txtImporte]').val(importe.toFixed(2));
     });estas a fill
     
     $('input[name=txtCantidad]').change(function() {
     var precio = $('input[name=txtPrecioUnitario]').val();
     var cant = $('input[name=txtCantidad]').val();
     var importe = precio * cant;
     
     $('input[name=txtImporte]').val(importe.toFixed(2));
     });*/
</script>